package campus.aiit.ssl.manage.cron;

import java.text.SimpleDateFormat;
import java.util.Date;

public class TimingJudgment {
    private static int lastTime = -1;

    public boolean CollectOrNot(int CollectionInterval){

        String nowTime = new SimpleDateFormat("mm").format(new Date());
//        System.out.println("PrintWordsJob start at:" + nowTime);
        int nowTime1 = Integer.valueOf(nowTime);
        if((nowTime1-lastTime >= CollectionInterval)||((lastTime+CollectionInterval>=60)&&(60+nowTime1-lastTime >= CollectionInterval))){
            lastTime = nowTime1;
            return true;
        }else if(lastTime==-1){
            lastTime = nowTime1;
            return true;
        }
        return false;
    }

}
